<include file="public@header" />
</head>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('room/index')}">班级列表</a></li>
        <li><a href="{:url('room/add')}">添加班级</a></li>
    </ul>
    <form class="well form-inline margin-top-20" method="post" action="{:url('room/index')}">
    <span>学校名称:</span>
        <select name="school_id" class="form-control">
            <option value="">--请选择学校--</option>
            <foreach name="school" item="vo">
                <php>$selectedSchool = $vo['id']==$school_id?"selected":""</php>
                <option value="{$vo.id}" {$selectedSchool}>{$vo.name}</option>
            </foreach>
            </select>
    <span>班级名称:</span>
        <input type="text" class="form-control" name="name" style="width: 120px;" placeholder="请输入班级"  value="{$Request.param.name}">
        <input type="submit" class="btn btn-primary" value="搜索" />
        <a class="btn btn-danger" href="{:url('room/index')}" name="">清空</a>
    </form>
    <form method="post" class="js-ajax-form margin-top-20" action="{:url('room/delAll')}">
        <div class="table-actions">
            <button class="btn btn-sm btn-danger js-ajax-submit" type="submit"  onclick="delAll()"
                    data-action="{:url('room/delAll')}" data-subcheck="true">批量删除
            </button>
        </div>
    <form  class="margin-top-20">
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
            <tr>
                <th width="16"><label><input type="checkbox" class="js-check-all" data-direction="x"
                                             data-checklist="js-check-x"></label></th>
                </th>
                <th width="80" align="center">ID</th>
                <th align="left" width="250px">班级名称</th>
                <th align="left" width="250px">学校名称</th>
                <th align="left" width="250px">量化总分</th>
                <th align="right"width="130">操作</th>
            </tr>
            </thead>
            <tbody>
           <foreach name="room" item="vo">
                <tr>
                    <td><input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
                               value="{$vo.id}"></td>
                    <td>{$key+1}</td>
                    <td>{$vo.name}</td>
                    <td>{$vo.school_name}</td>
                    <eq name="$vo.zongfen" value="">
                        <td> 0 </td>>
                        <else>
                    <td>{$vo.zongfen}</td>
                        </else>
                    </eq>
                    <td type="align:right">
                        <a class="btn btn-xs btn-primary " href="{:url('room/mingxi',array('id'=>$vo['id']))}">明细</a>
                         <a class="btn btn-xs btn-primary " href="{:url('room/edit',array('id'=>$vo['id']))}">编辑</a>
                         <a class="btn btn-xs btn-danger js-ajax-delete" class="" href="{:url('room/delete',array('id'=>$vo['id']))}">删除</a>
                    </td>
                </tr>
            </foreach>
            </tbody>
        </table>
    </form>
    </form>
    <div class="pagination">
        {$page}
    </div>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
    function delAll() {
        var ids = [];

        //获取选中的id
        $('tbody input').each(function (index,el) {
            if ($(this).prop('checked')){
                ids.push($(this).val())
            }
        });
        layer.confirm('确认要删除吗?',function (index) {
            //捉到所有被选中的，发异步进行删除
            $.ajax({
                url: "{:url('room/delAll')}",
                type: "POST",
                data: {ids:ids},
                success: function (res) {
                    if (res.code == 200){
                        layer.msg(res.msg,{icon:1});
                        setTimeout(function () {
                            location.reload();
                        },1500);
                    } else {
                        layer.msg(res.msg);
                        return false;
                    }
                }
            });
        });
    }
    </script>
</body>
</html>